#include "transactionmodel.h"

TransactionModel::TransactionModel()
{
    int i;

    this->saleTime = QDateTime::currentDateTime();
    this->customer = new CustomerModel;
    this->lastModified = this->saleTime;
    this->deliveryStatus = "ORDERED";
    this->paid = false;

    for (i = 0; i < 5; i++) {
        this->stocks.append(new StockModel);
    }
}

void TransactionModel::setStocks(QList<StockModel *> stocks)
{
    this->stocks = stocks;
}

QList<StockModel *> TransactionModel::getStocks()
{
    return this->stocks;
}

QDateTime TransactionModel::getSaleTime()
{
    return this->saleTime;
}

void TransactionModel::setSaleTime(QDateTime date)
{
    this->saleTime = date;
}

CustomerModel *TransactionModel::getCustomer()
{
    return this->customer;
}

void TransactionModel::setCustomer(CustomerModel *customer)
{
    this->customer = customer;
}

QDateTime TransactionModel::getLastModificationTime()
{
    return this->lastModified;
}

void TransactionModel::updateLastModificationTime()
{
    this->lastModified = QDateTime::currentDateTime();
}

void TransactionModel::setLastModificationTime(QDateTime datetime)
{
    this->lastModified = datetime;
}

QString TransactionModel::getDeliveryStatus()
{
    return this->deliveryStatus;
}

void TransactionModel::setDeliveryStatus(QString deliveryStatus)
{
    // TODO verify the deliveryStatus here

    this->deliveryStatus = deliveryStatus;
}

bool TransactionModel::isPaid()
{
    return this->paid;
}

void TransactionModel::setPaid(bool paid)
{
    this->paid = paid;
}

bool TransactionModel::isValid()
{
    return this->valid;
}

void TransactionModel::setValid(bool valid)
{
    this->valid = valid;
}
